/**
 * Yotaku Shop - yshop
 * @author Creatint<creatint@163.com>
 * @copyright www.yotaku.cn 2016
 */
$(function(){
    /**
     * 左侧菜单栏 - 折叠效果
     */
    $(document).on('click','#side-left .menu>ul>li>a',function(){
        if($(this).hasClass('open') && !$(this).hasClass('active')){
            $(this).next().css('display','none');
        }else{
            $(this).next().css('display','block');
        }
        $(this).hasClass('open')?$(this).removeClass('open'):$(this).addClass('open');
    });
    $(document).on('mouseout','.menu>ul>li>a',function(){
        $(this).next().attr('style','');
    });



    // $(document).on('change',"input[name='multimage']",function(){
    //     //fileUpload();
    //
    // });
    var fileUpload = function(){
        trace('上传图片函数');
        trace($("input[name='multimage']"));
        // // var picture = $("input[name='multimage']");
        // var picture = document.getElementById("multimage");
        // var files = new FormData(picture,'multimage');
        //
        // files = FileList;
        //
        // trace(picture);
        // // var files = new FormData();
        // // files.append( "code", '5');
        // //files.append( "multimage", );
        // trace(files);


        var fd = new FormData();
        fd.append("name", "脚本之家");
        fd.append("blog", "http://jb51.net");
        fd.append("file", document.getElementById("multimage"));


        $.ajax({
            type: "POST",
            url: "http://yshop/index.php/Admin/Picture/upload",
            data: fd,
            contentType: false,   // tell jQuery not to set contentType
            processData: false,  // tell jQuery not to process the data
            success: function(data) {
                trace(data);
                trace("上传成功");
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                trace(errorThrown);
                trace(textStatus);
                trace("上传失败");
            }
        });
    }


});

var trace = function(data){
    console.log(data);
};
